package org.visionlibrary.image.filters.nonlinear;

import java.awt.Point;

import javax.media.jai.TiledImage;

import org.visionlibrary.image.model.WindowFilter;


public class Uolis extends WindowFilter {
	protected int getNewPixelVal(TiledImage src, Point p, int channel) {
		double upper = (Math.pow(getWindowPixelVal(src, dstPointInWindow,
				channel), 4.0));
		double lower = (double) getWindowPixelVal(src, new Point(
				dstPointInWindow.x - 1, dstPointInWindow.y), channel)
				* getWindowPixelVal(src, new Point(dstPointInWindow.x + 1,
						dstPointInWindow.y), channel)
				* getWindowPixelVal(src, new Point(dstPointInWindow.x,
						dstPointInWindow.y + 1), channel)
				* getWindowPixelVal(src, new Point(dstPointInWindow.x,
						dstPointInWindow.y - 1), channel);

		double log = Math.log(upper / lower);

		double val = 0.25 * log;
		return (int) val;
	}

	protected void setWindowProperties() {
		windowWidth = 3;
		windowHeight = 3;
		dstPointInWindow = new Point(1, 1);
	}
}
